//
//  UserInfoButton.m
//  ECBBusinessCamp
//
//  Created by rimi on 16/6/29.
//  Copyright © 2016年 邓毕华. All rights reserved.
//

#import "UserInfoButton.h"

@implementation UserInfoButton

#pragma mark 🌷🌷🌷life cycle🌷🌷🌷
- (instancetype)init
{
    self = [super init];
    if (self) {
        self.layer.borderColor = RGB_COLOR(208, 208, 208, 1).CGColor;
        self.layer.borderWidth = 1;
        
        // 添加视图
        [self addSubview:self.headImageView];
        [self addSubview:self.nameLabel];
        [self addSubview:self.infoLabel];
        [self addSubview:self.memorySizeLabel];
        [self addSubview:self.extensionImageView];
        
        // 自动布局
        [_headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.width.equalTo(self.mas_height).multipliedBy(0.8);
            make.centerY.equalTo(self);
            make.centerX.equalTo(self).multipliedBy(0.15);
        }];
        [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self);
            make.left.equalTo(_headImageView.mas_right).offset(5);
        }];
        [_infoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self);
            make.left.offset(SCREEN_WIDTH * 0.01);
        }];
        [_memorySizeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self);
            make.right.offset(SCREEN_WIDTH * -0.02);
        }];
        [_extensionImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.offset(SCREEN_HEIGHT * 0.014);
            make.width.equalTo(_extensionImageView.mas_height).multipliedBy(0.77);
            make.centerY.equalTo(self);
            make.centerX.equalTo(self).multipliedBy(1.9);
        }];
    }
    return self;
}

#pragma mark 🌷🌷🌷getters and setters🌷🌷🌷
- (UIImageView *)headImageView {
    if (!_headImageView) {
        _headImageView = [[UIImageView alloc] init];
    }
    return _headImageView;
}
- (UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.font = [UIFont systemFontOfSize:20];
        _nameLabel.textColor = RGB_COLOR(145, 201, 218, 1);
    }
    return _nameLabel;
}
- (UILabel *)infoLabel {
    if (!_infoLabel) {
        _infoLabel = [[UILabel alloc] init];
        _infoLabel.textColor = RGB_COLOR(128, 128, 128, 1);
        _infoLabel.font = [UIFont systemFontOfSize:20];
    }
    return _infoLabel;
}
- (UILabel *)memorySizeLabel {
    if (!_memorySizeLabel) {
        _memorySizeLabel = [[UILabel alloc] init];
        _memorySizeLabel.textColor = RGB_COLOR(124, 165, 177, 1);
        _memorySizeLabel.font = [UIFont systemFontOfSize:20];
    }
    return _memorySizeLabel;
}
- (UIImageView *)extensionImageView {
    if (!_extensionImageView) {
        _extensionImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"展开符"]];
    }
    return _extensionImageView;
}
- (UIView *)grayView {
    if (!_grayView) {
        _grayView = [[UIView alloc] init];
        _grayView.backgroundColor = RGB_COLOR(208, 208, 208, 1);
    }
    return _grayView;
}

@end
